<?php
////陈华项目
//首页显示路径
Route::get('/', function () {
    return view('welcome');
});
//显示视图
Route::get('view','ViewController@index');
Route::get('view/test','ViewController@indexTest');

//命名路由
/*Route::get('user',['as'=>'profile',function(){
    return "命名路由";
}]);*/

//路由分组，前缀，命名空间都能放进去
//Route::group(['prefix' => 'admin','namespace'=>'Admin','middleware'=>['web','admin.log']], function () { //prefix是前缀
//    Route::get('index','IndexController@index');
//    Route::resource('article', 'ArticleController');
//});

//中间键
//Route::group(['middleware'=>['web']],function (){
//    Route::get('admin/login','Admin\IndexController@login');
//    Route::get('/', function () {
//        session(['key'=>234]);
//        return view('welcome');
//    });
//
//    Route::get('sess', function () {
//        echo session('key');
//        return 'kankansession';
//    });
//});





//首页显示路径


////post请求
//Route::post('/hd', function () {
//    echo "post";
//    //return view('welcome');
//});
////不限方式请求
//Route::any('foo', function () {
//    echo 'foo';
//});
////1.传递一个参数的情况   {id}  直接赋值给了 function中的$d了~
////2.加上where条件，用正则的方式限制只能输入数字
//Route::get('user/{id}', function ($d) {
//    return  'User '.$d;
//})->where('id','[0-9]+');
////传递多个参数的情况
//Route::get('posts/{post}/comments/{comment}', function ($para, $para2) {
//    echo $para;
//    echo "<hr>";
//    return $para2;
//});




//指定命名空间的路由
/*Route::group(["namespace"=>"Admin"],function (){
    Route::get("/test","IndexController@test");
    Route::get("/login","loginController@login");
    Route::post("/login/loginCheck","loginController@loginCheck");
});






//模型学习
Route::get("/model/select","adminController@select"); //定义查
Route::get("/model/insert","adminController@insert"); //定义增
Route::get("/model/update","adminController@update"); //定义改
Route::get("/model/delete","adminController@delete"); //定义删

//视图学习
Route::get("/view","viewController@show");
Route::get("/view/blade","viewController@blade");
Route::get("/view/if","viewController@if1");//blade模板if语句用法
Route::get("/view/loop","viewController@loop");//blade模板for循环语句用法
Route::get("/view/template","viewController@template");//blade模板继承


//返回json数据
Route::get("/response","ResponseController@rj");
//response download
Route::get("/response","ResponseController@downCode");
//request类的用法
Route::get("/request","RequestController@req");
Route::get("/request/add","RequestController@add");
//显示form视图
Route::get("/form",function (){
    return view("form");
});

Route::get("/student","StudentController@index");
Route::get("/student/display","StudentController@display");
Route::get("/student/red","StudentController@red");
Route::get("/student/redToAction","StudentController@redToAction");
//redirect方法带上参数传递到具体的控制器
Route::get('/student/red2a',"StudentController@red2a");

//以下为各种路由形式，记得多看看，多用用
//  get方法获取路由
Route::get("/user","UserController@index");

//用controller来做,那么就可以直接访问以下路由了：/controller/test
//get后面，可以加上方法名称
Route::controller("controller","UserController");

//带有参数的路由(在url地址中，使用花括号包含id,表示该位置需要传递参数，在匿名函数中，必须带上$id这个参数，参数必须和花括号的字符串一样)
Route::get('/stu/{id}',function ($id){
    return "学生id=".$id;
});

//带有多个参数的url写法
Route::get("/stu/{name}/id/{id}",function ($name,$id){
    return "姓名是".$name."   学号是".$id;
});

//带有参数的url传到控制器中
//Route::get("/index/{id}","IndexController@index");
//可选参数的url传到控制器中，就是加个问号，同时控制器方法中的形参必须给一个默认值
Route::get("/index/{id?}","IndexController@index");


//路由群组  一条返回用户id和名称
Route::group(['prefix'=>'user'],function (){
    Route::get("id","UserController@getId");
    Route::get("name","UserController@getName");
});*/
